home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / lib / xulrunner-1.9.0.14 / chrome / pippki.jar / content / pippki / crlImportDialog.js < prev    next >
Encoding:
Text File  |  2006-07-13  |  4.6 KB  |  118 lines

  1. /* ***** BEGIN LICENSE BLOCK *****
  2.  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  3.  *
  4.  * The contents of this file are subject to the Mozilla Public License Version
  5.  * 1.1 (the "License"); you may not use this file except in compliance with
  6.  * the License. You may obtain a copy of the License at
  7.  * http://www.mozilla.org/MPL/
  8.  *
  9.  * Software distributed under the License is distributed on an "AS IS" basis,
  10.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  11.  * for the specific language governing rights and limitations under the
  12.  * License.
  13.  *
  14.  * The Original Code is mozilla.org code.
  15.  *
  16.  * The Initial Developer of the Original Code is
  17.  * Netscape Communications Corporation.
  18.  * Portions created by the Initial Developer are Copyright (C) 2001
  19.  * the Initial Developer. All Rights Reserved.
  20.  *
  21.  * Contributor(s):
  22.  *   Rangan Sen <rangansen@netscape.com>
  23.  *
  24.  * Alternatively, the contents of this file may be used under the terms of
  25.  * either the GNU General Public License Version 2 or later (the "GPL"), or
  26.  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  27.  * in which case the provisions of the GPL or the LGPL are applicable instead
  28.  * of those above. If you wish to allow use of your version of this file only
  29.  * under the terms of either the GPL or the LGPL, and not to allow others to
  30.  * use your version of this file under the terms of the MPL, indicate your
  31.  * decision by deleting the provisions above and replace them with the notice
  32.  * and other provisions required by the GPL or the LGPL. If you do not delete
  33.  * the provisions above, a recipient may use your version of this file under
  34.  * the terms of any one of the MPL, the GPL or the LGPL.
  35.  *
  36.  * ***** END LICENSE BLOCK ***** */
  37.  
  38. const nsPKIParamBlock    = "@mozilla.org/security/pkiparamblock;1";
  39. const nsIPKIParamBlock    = Components.interfaces.nsIPKIParamBlock;
  40. const nsIX509Cert         = Components.interfaces.nsIX509Cert;
  41. const nsICRLInfo          = Components.interfaces.nsICRLInfo;
  42. const nsIPrefService      = Components.interfaces.nsIPrefService
  43.  
  44. var pkiParams;
  45. var cert;
  46. var crl;
  47.  
  48. function onLoad()
  49. {
  50.   pkiParams = window.arguments[0].QueryInterface(nsIPKIParamBlock);  
  51.   isupport = pkiParams.getISupportAtIndex(1);
  52.   if (isupport) {
  53.     crl = isupport.QueryInterface(nsICRLInfo);
  54.   }
  55.   var bundle = srGetStrBundle("chrome://pippki/locale/pippki.properties");
  56.   var yesButton = bundle.GetStringFromName("yesButton");
  57.   var noButton = bundle.GetStringFromName("noButton");
  58.   document.documentElement.getButton("accept").label = yesButton;
  59.   document.documentElement.getButton("cancel").label = noButton;
  60.   
  61.   var nextUpdateStr;
  62.   var orgStr;
  63.   var orgUnitStr;
  64.  
  65.   if(crl != null) {    
  66.     nextUpdateStr = crl.nextUpdateLocale;
  67.     if( (nextUpdateStr == null) || (nextUpdateStr.length == 0) ){
  68.       nextUpdateStr = bundle.GetStringFromName("undefinedValStr");
  69.     }
  70.     var nextUpdate = document.getElementById("nextUpdate");
  71.     nextUpdate.setAttribute("value",nextUpdateStr);
  72.     var org = document.getElementById("orgText");
  73.     org.setAttribute("value", crl.organization);
  74.     var orgUnit = document.getElementById("orgUnitText");
  75.     orgUnit.setAttribute("value", crl.organizationalUnit);
  76.  
  77.     var autoupdateEnabledString   = "security.crl.autoupdate.enable." + crl.nameInDb;
  78.     
  79.     var updateEnabled = false;
  80.     try {
  81.       var prefService = Components.classes["@mozilla.org/preferences-service;1"].getService(nsIPrefService);
  82.       var prefBranch = prefService.getBranch(null);
  83.       updateEnabled = prefBranch.getBoolPref(autoupdateEnabledString);
  84.       if(updateEnabled) {
  85.         var autoupdateURLString       = "security.crl.autoupdate.url." + crl.nameInDb;
  86.         prefBranch.setCharPref(autoupdateURLString, crl.lastFetchURL);
  87.         prefService.savePrefFile(null);
  88.       }
  89.     }catch(exception){}
  90.  
  91.     var statement = document.getElementById("status");
  92.     var question = document.getElementById("question");
  93.     if(updateEnabled) {
  94.       statement.setAttribute("value",bundle.GetStringFromName("enabledStatement"));
  95.       question.setAttribute("value",bundle.GetStringFromName("crlAutoupdateQuestion2"));
  96.     } else {
  97.       statement.setAttribute("value",bundle.GetStringFromName("disabledStatement"));
  98.       question.setAttribute("value",bundle.GetStringFromName("crlAutoupdateQuestion1"));
  99.     }
  100.   }  
  101. }
  102.  
  103. function onCancel()
  104. {
  105.   return true;
  106. }
  107.  
  108.  
  109. function onAccept()
  110. {
  111.   var params = Components.classes[nsPKIParamBlock].createInstance(nsIPKIParamBlock);
  112.   params.setISupportAtIndex(1, crl);
  113.   
  114.   window.openDialog("chrome://pippki/content/pref-crlupdate.xul","",
  115.                     "chrome,centerscreen,modal",params);
  116.   return true;
  117. }
  118.